package com.crazy.shell.config.linstener;

import com.crazy.shell.config.event.CustomEvent;
import com.crazy.shell.config.event.CustomEventPulisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;

import java.util.Set;

/**
 * Created by creazier.huang on 16/9/30.
 */
public class AppPreLinstener implements ApplicationListener<ApplicationPreparedEvent> {
    private  final Logger logger = LoggerFactory.getLogger(AppPreLinstener.class);

    @Autowired
    private CustomEventPulisher pulisher;

    @Override
    public void onApplicationEvent(ApplicationPreparedEvent event) {
        logger.info("AppPreLinstener order");
        pulisher.publish();

        Set<ApplicationListener<?>> listenerSet = event.getSpringApplication().getListeners();
        listenerSet.forEach(set->{
        });
    }
}
